package com.example.controller;

import com.example.common.Result;
import com.example.entity.Trainings;
import com.example.entity.User;
import com.example.service.TrainingService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/training")
public class TrainingController {
    @Resource
    private TrainingService trainingService;

    @PostMapping("/add")
    private Result addTraining(@RequestBody List<Trainings> trainingsList){
        return trainingService.addTraining(trainingsList);
    }

    @PostMapping("/list")
    private Result listTraining(@RequestBody User user){
        return trainingService.listTraining(user);
    }

    @PostMapping("/listAll")
    private Result listAll(){
        return trainingService.listAll();
    }

    @PostMapping("/delete")
    private Result deleteTraining(@RequestBody Trainings trainings){
        return trainingService.deleteTraining(trainings);
    }

    @PostMapping("/update")
    private Result updateTraining(@RequestBody Trainings trainings){
        return trainingService.updateTraining(trainings);
    }
}
